//
//  Development_List_Vc.swift
//  LocaLink
//
//  Created by Icy on 2017/1/16.
//  Copyright © 2017年 Icy. All rights reserved.
//

/*
 owner:cy
 update2017年01月16日21:28:05
 info: 社区列表选择
 */
import RxSwift
import UtilCore

class Development_List_Vc: Base_Vc {
    
    /****************************Storyboard UI设置区域****************************/
    
    @IBOutlet weak var close_Btn: UIButton!

    @IBOutlet weak var search_Btn: UIButton!
    ///是否从登陆界面进入
    var isModal:Bool = false
    /*----------------------------   自定义属性区域    ----------------------------*/
    
    
    var developmentList:[DevelopmentModel]?
    /****************************Storyboard 绑定方法区域****************************/
    
    
    
    /**************************** 以下是方法区域 ****************************/
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    /**
     界面基础设置
     */
    override func setupUI() {
        /**
         *  自定义 导航栏左侧 返回按钮
         */
        self.customLeftBarButtonItem()
        

        
    }
    
    /**
     绑定到viewmodel 设置
     */
    override func bindToViewModel(){
        self.close_Btn
            .rx.tap
            .subscribe(onNext: { [unowned self] ( _ ) in
              self.navigationController?.popViewController(animated: true)
            })
            .disposed(by: disposeBag)
    }
    
    /**
     自定义leftBarButtonItem
     */
    override func customLeftBarButtonItem()  {
        
    }
    
    
    
}
// MARK: UITableViewDelegate
extension Development_List_Vc :UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
        return self.developmentList?.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
        let cell = tableView.dequeueReusableCell(withIdentifier: "Development_TCell", for: indexPath) as! Development_TCell
        cell.name_Lb.text = self.developmentList![indexPath.row].address
        return cell
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
}
// MARK: UITableViewDelegate
extension Development_List_Vc: UITableViewDelegate {
    /// 点击行事件
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
        if isModal {
            self.dismiss(animated: true, completion: nil)
        }else{
            let appdelegate = UIApplication.shared.delegate as! AppDelegate
            appdelegate.setTabBarVc()
        }
    }
    
}

